<?php
include_once 'class/LogParser.acalss.inc';
include_once 'class/LogReader.aclass.inc';
class PassedAuthenticationsLogParser extends LogParser {
	private $pattern = '%(?P<date>(?P<month>\d{2})/(?P<day>\d{2})/(?P<year>\d{4})),(?P<time>\d{2}:\d{2}:\d{2}),(?P<message_type>[\w ]*),(?P<username>[\w\d./@_\-:]*),(?P<groupname>[\w\d./@-_:&+ ]*),(?P<caller_id>[\w.\-
/:=]*),(?P<nas_port>[\d./]*),(?P<nas_ip_address>[\d.]*),(?P<peap_eap_fast_clear_name>[\w]*),(?P<eap_type>[\d]*),(?P<eap_type_name>[\w-]*),(?P<cisco_av_pair>[\w]*),(?P<access_device>[\w-]*),(?P<extdb_info>[\w]*)%';

	protected function parser($log) {
		$matches = null;
		if(0 === preg_match($this->pattern, $log, $matches))
		return false;

		return $matches;
	}
	public function getDBVersion($log) {
		$res = array(
			'date' => $log['year']."-".$log['month']."-".$log['day']." ".$log['time'],
			'message_type' => $log['message_type'],
			'username' => $log['username'],
			'groupname' => $log['groupname'],
			'caller_id' => $log['caller_id'],
			'nas_port' => $log['nas_port'],
			'nas_ip_address' => $log['nas_ip_address'],
			'peap_eap_fast_clear_name' => $log['peap_eap_fast_clear_name'],
			'eap_type' => $log['eap_type'],
			'eap_type_name' => $log['eap_type_name'],
			'cisco_av_pair' => $log['cisco_av_pair'],
			'access_device' => $log['access_device'],
			'extdb_info' => $log['extdb_info']
			);
			
		return $res;
	}
	
public function getName() {
		return 'passed_auth';
	}
}
?>